package cn.tedu.jdbc;

import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

/*
Author     :Dsi
Date       : 2021/11/30 17:04
Description: 
*/
public class Test02 {
    @Test
    public void test() throws Exception {
        Connection connection = JDBUtils.getDriver("jdbc:mysql//localhost:3307/cgb1129","root","root");
        //获取数据库的传输器
        Statement statement = connection.createStatement();
        //执行sql语句
        String sql="select * from students";
        ResultSet resultSet = statement.executeQuery(sql);

        for (; resultSet.next(); ) {
            for (int j = 1; j <=5; j++) {
                Object object = resultSet.getObject(j);
                System.out.print(object+" ");
                if (j == 5) break;
            }
            System.out.println();
        }
        connection.close();
        statement.close();
        resultSet.close();
    }
}

